<?php
namespace Home\Controller;
use Think\Controller;
class VideoController extends Controller{
    public function index(){
        $this->display();
    }
    public function play(){
        $this->display();
    }
    public function test(){
        $this->makes_dir("./Uploads/");
    }
    public function upload(){
        if(!$this->makes_dir("./Uploads/")){
            echo '创建目录失败';
            return;
        }
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize   =     524288000 ;// 设置附件上传大小
        $upload->exts      =     array('avi', 'rmvb', 'mp4', 'kmv');// 设置附件上传类型
        $upload->rootPath  =     './Uploads/'; // 设置附件上传根目录
        $upload->savePath  =     ''; // 设置附件上传（子）目录
        $upload->saveName ='time';
        // 上传文件 
        $info   =   $upload->upload();
        if(!$info) {// 上传错误提示错误信息
            $this->error($upload->getError());
        }else{// 上传成功
            $this->success('上传成功！');
        }
    }
    private function makes_dir($dir){
        if(is_dir($dir)){
            return true;
        }
        else{
            if(mkdir($dir)){
                return true;
            }
            else{
                return false;
            }
        }
    }
}